import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

// 引入组件 【默认只引入两个组件，其他组件使用懒加载（访问它的地址，才会加载对应组件）】
import Login from '@/views/login/Login.vue'
import Layout from '@/views/layout/Layout.vue'

/* *********** 路由配置 *********** */
const routes = [
  // 登录
  {
    path: '/login',
    component: Login
  },
  // 后台首页
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: '/home',
        component: () => import('@/views/home/Home.vue')
      }
    ]
  },
  // 账号管理
  {
    path: '/account',
    component: Layout,
    redirect: '/account/account-list',
    children: [
      {
        path: '/account/account-list',
        component: () => import('@/views/account/AccountList.vue')
      },
      {
        path: '/account/account-add',
        component: () => import('@/views/account/AccountAdd.vue')
      },
      {
        path: '/account/password-modify',
        component: () => import('@/views/account/PasswordModify.vue')
      },
      {
        path: '/account/personal',
        component: () => import('@/views/account/Personal.vue')
      }
    ]
  },
  // 商品管理
  {
    path: '/goods',
    component: Layout,
    redirect: '/goods/goods-list',
    children: [
      {
        path: '/goods/goods-list',
        component: () => import('@/views/goods/GoodsList.vue')
      },
      {
        path: '/goods/goods-add',
        component: () => import('@/views/goods/GoodsAdd.vue')
      },
      {
        path: '/goods/goods-cate',
        component: () => import('@/views/goods/GoodsCate.vue')
      },
    ]
  },
  // 订单管理
  {
    path: '/order',
    component: Layout,
    children: [
      {
        path: '',
        component: () => import('@/views/order/Order.vue')
      },
    ]
  },
  // 店铺管理
  {
    path: '/shop',
    component: Layout,
    children: [
      {
        path: '',
        component: () => import('@/views/shop/Shop.vue')
      },
    ]
  },
  // 销售统计
  {
    path: '/total',
    component: Layout,
    redirect: '/total/goods-total',
    children: [
      {
        path: '/total/goods-total',
        component: () => import('@/views/total/GoodsTotal.vue')
      },
      {
        path: '/total/order-total',
        component: () => import('@/views/total/OrderTotal.vue')
      },
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
